package com.ukao.cashregister.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;
import android.widget.TextView;

import com.amap.api.services.core.PoiItem;
import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.consts.Constant;

import java.util.List;



/**
 * Created by ukaodev on 2017/6/14.
 */

public class AddressAdapter extends CommonAdapter<PoiItem> {


    private final Bitmap imgMarker;

    public AddressAdapter(Context context, List<PoiItem> datas  ) {
        super(context, datas, R.layout.adapter_add_dress);
        imgMarker= BitmapFactory.decodeResource(mContext.getResources(), R.drawable.poi_marker_red);
    }

    @Override
    public void convert(ViewHolder holder, PoiItem testBean) {

        ImageView image=holder.getView(R.id.image);
        image.setImageBitmap(Constant.createDrawable(String.valueOf(holder.getLayoutPosition()+1),imgMarker));
        ((TextView) holder.itemView.findViewById(R.id.snippet)).setText(testBean.getSnippet());
        ((TextView) holder.itemView.findViewById(R.id.title)).setText(testBean.getTitle());

        if(testBean.getDistance()==1){
            holder.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.blue_color));
        }else{
            holder.itemView.setBackgroundResource(R.color.white);
        }



    }


}
